SET QUOTED_IDENTIFIER ON
GO
SET ANSI_NULLS ON
GO

CREATE PROC [dbo].[PResultWorkINSERT]
@Ik_ListReq INT,
@idUspevDocs INT,
@SystemNumber INT,
@LoadDoc varchar(max) output
AS
BEGIN
SET NOCOUNT ON;
--DECLARE @SystemNumber INT
--SELECT @SystemNumber=MAX(SystemNumber) 
--FROM ResultWork
--SET @SystemNumber=@SystemNumber+3 
DECLARE @ID UNIQUEIDENTIFIER
SET @ID = NEWID()
INSERT INTO ResultWork
(Ik_ResultWork,Ik_ListReq,idUspevDocs,SystemNumber,LoadDoc,DATELOAD)
VALUES (@ID,@Ik_ListReq,@idUspevDocs,@SystemNumber,CAST('' AS VARBINARY(MAX)),GETDATE());

select @LoadDoc = LoadDoc.PathName() from ResultWork where Ik_ResultWork = @ID
END

GO
